import Vue from 'vue'
import VueRouter from 'vue-router'
import Login from '../views/Login.vue'
import Home from '../views/Home.vue'
import Index from '../views/Index.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    name: 'Login',
    component: Login,
    hidden:true
  },
  {
    path: '/home',
    name: 'Home',
    component: Home,
    hidden: true,
    children: [
      {
        path: '/',
        name: '主页',
        component: Index
      }
    ]
  }
  
]

const router = new VueRouter({
  routes
})

/**
 * 动态添加路由时，清空一下之前的路由
 * @param {路由信息} params 
 */
router.selfaddRoutes = function (params){
  router.matcher = new VueRouter().matcher;
  router.addRoutes(params)
}
export default router
